﻿using System;
using System.Drawing;

namespace uTILLIty.Outlook.FlexFileAddIn
{
  public class CandidateFolderInfo : IComparable
  {
    protected readonly FolderInfo WrappedFolder;

    public CandidateFolderInfo(FolderInfo wrappedFolder, int displayPriority, string candidateReasonDescription)
    {
      if (wrappedFolder == null)
        throw new ArgumentNullException("wrappedFolder");
      
      WrappedFolder = wrappedFolder;
      DisplayPriority = displayPriority;
      CandidateReasonDescription = candidateReasonDescription;
      
      ForeColor = Color.Black;
      BackColor = Color.White;
    }

    public CandidateFolderInfo(FolderInfo wrappedFolder, int displayPriority, string candidateReasonDescription, Color foreColor, Color backColor)
      : this (wrappedFolder, displayPriority, candidateReasonDescription)
    {
      ForeColor = foreColor;
      BackColor = backColor;
    }

    public FolderInfo FolderInfo
    {
      get { return WrappedFolder; }
    }

    public FolderInfo Parent
    {
      get { return WrappedFolder.Parent; }
      set { WrappedFolder.Parent = value; }
    }

    public string Name
    {
      get { return WrappedFolder.Name; }
      set { WrappedFolder.Name = value; }
    }

    public string FolderId
    {
      get { return WrappedFolder.FolderId; }
      set { WrappedFolder.FolderId = value; }
    }

    public string FullName
    {
      get { return WrappedFolder.FullName; }
      set { WrappedFolder.FullName = value; }
    }

    public StoreInfo Store
    {
      get { return WrappedFolder.Store; }
      set { WrappedFolder.Store = value; }
    }

    public string ParentPath
    {
      get { return WrappedFolder.ParentPath; }
    }

    public string SortingName
    {
      get { return string.Format("{0} {1}", DisplayPriority, Name.ToLowerInvariant()); }
    }

    //public bool IsMailBasedCandidate { get; set; }
    public int DisplayPriority { get; set; }
    public string CandidateReasonDescription { get; set; }
    public Color ForeColor { get; set; }
    public Color BackColor { get; set; }

    public int CompareTo(object obj)
    {
      var target = obj as CandidateFolderInfo;
      if (target == null)
        return -1;
      return WrappedFolder.CompareTo(target.FolderInfo);
    }

    public override string ToString()
    {
      return WrappedFolder.ToString();
    }

    public override bool Equals(object obj)
    {
      return CompareTo(obj) == 0;
    }

    public override int GetHashCode()
    {
      return WrappedFolder.GetHashCode();
    }
  }
}